﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QBWeb.Models.QuestionFolder;
using QBWeb.Models.TestFolder;

namespace QBWeb.Models
{
    public class AddQuestion
    {
        /// <summary>
        /// 单选题
        /// </summary>
        /// <param name="questions"></param>
        /// <param name="singleChoice"></param>
        /// <returns></returns>
        public Dictionary<int, Dictionary<string, string>> CutQuestion(TestDetailsTb testDetails,int questionIndex, QuestionTb questions, SingleChoiceTb singleChoice)
        {
            var dicDic = new Dictionary<int, Dictionary<string, string>>();

            var tempDict = new Dictionary<string, string>
            {
                ///试卷
                ["testDetailsId"] = testDetails.Id.ToString(),
                ["score"] = testDetails.Score.ToString(),

                ///题目类型
                ["type"] = questions.QuestTypeTbId.ToString(),

                //题目表数据
                ["questionId"] = questions.Id.ToString(),
                ["smallKnowModuleTbId"] = questions.SmallKnowModuleTbId.ToString(),
                ["questName"] = questions.QuestName,
                ["questAnalysis"] = questions.QuestAnalysis,
                ["questLevel"] = questions.QuestLevel.ToString(),

                //选择题表数据
                ["options"] = singleChoice.Options,
                ["Value"] = singleChoice.Value,
                ["choiceValue"] = singleChoice.CorrectOption.ToString()
            };

            dicDic.Add(questionIndex, tempDict);
            return dicDic;
        }

        /// <summary>
        /// 判断题
        /// </summary>
        /// <param name="questions"></param>
        /// <param name="trueFalse"></param>
        /// <returns></returns>
        public Dictionary<int, Dictionary<string, string>> CutQuestion(TestDetailsTb testDetails,int questionIndex, QuestionTb questions, TrueFalseTb trueFalse)
        {
            var dicDic = new Dictionary<int, Dictionary<string, string>>();
            var tempDict = new Dictionary<string, string>
            {
                ///试卷
                ["testDetailsId"] = testDetails.Id.ToString(),
                ["score"] = testDetails.Score.ToString(),

                //题目类型
                ["type"] = questions.QuestTypeTbId.ToString(),

                //题目表数据
                ["questionId"] = questions.Id.ToString(),
                ["smallKnowModuleTbId"] = questions.SmallKnowModuleTbId.ToString(),
                ["questName"] = questions.QuestName,
                ["questAnalysis"] = questions.QuestAnalysis,
                ["questLevel"] = questions.QuestLevel.ToString(),

                //判断题表数据
                ["correctValue"] = trueFalse.CorrectValue.ToString()
            };

            dicDic.Add(questionIndex, tempDict);
            return dicDic;
        }

        /// <summary>
        /// 填空题
        /// </summary>
        /// <param name="questions"></param>
        /// <param name="blanks"></param>
        /// <returns></returns>
        public Dictionary<int, Dictionary<string, string>> CutQuestion(TestDetailsTb testDetails,int questionIndex, QuestionTb questions, BlanksTb blanks)
        {
            var dicDic = new Dictionary<int, Dictionary<string, string>>();
            var tempDict = new Dictionary<string, string>
            {
                ///试卷
                ["testDetailsId"] = testDetails.Id.ToString(),
                ["score"] = testDetails.Score.ToString(),

                //题目类型
                ["type"] = questions.QuestTypeTbId.ToString(),

                //题目表数据
                ["questionId"] = questions.Id.ToString(),
                ["smallKnowModuleTbId"] = questions.SmallKnowModuleTbId.ToString(),
                ["questName"] = questions.QuestName,
                ["questAnalysis"] = questions.QuestAnalysis,
                ["questLevel"] = questions.QuestLevel.ToString(),

                //判断题表数据
                ["correctValue"] = blanks.CorrectValue
            };

            dicDic.Add(questionIndex, tempDict);
            return dicDic;
        }
    }
}